package com.situ.stl.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.situ.stl.model.Coach;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface CoachMapper extends BaseMapper<Coach> {

    default Page<Coach> findAll(Page<Coach> page, Coach coach) {
        LambdaQueryWrapper<Coach> qw = Wrappers.lambdaQuery();

        // 若姓名不为空，添加模糊查询条件
        if (coach.getName() != null && !coach.getName().isEmpty()) {
            qw.like(Coach::getName, coach.getName());  // 模糊匹配姓名
        }

        // 若手机号不为空，添加模糊查询条件
        if (coach.getPhone() != null && !coach.getPhone().isEmpty()) {
            qw.like(Coach::getPhone, coach.getPhone());  // 模糊匹配手机号
        }


        // 执行分页查询
        return selectPage(page, qw);
    }




}

